// 麻将游戏UI预制体管理

let uiCreator = function() {
    let that = {};

    // 提示消息
    that.createScreenMsg = function (msg) {
        cc.loader.loadRes("Prefabs/ScreenMessage", (err, prefab)=>{
            if (!err) {
                var node = cc.instantiate(prefab);
                cc.director.getScene().getChildByName('Canvas').addChild(node);
                node.setPosition(cc.p(0, 0));
                node.getComponent("ScreenMessagr").showMessage(msg);
            }
        });
    };

    // 退出游戏界面
    that.createOutGame = function (callback) {
        cc.loader.loadRes("Prefabs/PromptBox", (err, prefab)=>{
            if (!err) {
                var node = cc.instantiate(prefab);
                node.getComponent("PromptBox").SetCallbackFun(callback);
                cc.director.getScene().getChildByName('Canvas').addChild(node);
            }
        });
    };

    // 聊天界面
    that.createChat = function (self) {
        cc.loader.loadRes("Prefabs/Game/Emotions/Chat", (err, prefab)=>{
            if (!err) {
                var node = cc.instantiate(prefab);
                node.getComponent("Chat").SetNode(self);
                cc.director.getScene().getChildByName('Canvas').addChild(node);
            }
        });
    };

    // 结算界面界面
    that.createSettlement = function (playerID, data) {
        cc.loader.loadRes("Prefabs/Game/HuaShui/JieSuan", (err, prefab)=>{
            if (!err) {
                var node = cc.instantiate(prefab);
                cc.director.getScene().getChildByName('Canvas').addChild(node);
                node.getComponent("JieSuan").SetDataFun(playerID, data);
            }
        });
    };






    return that;
};
export default uiCreator;